﻿namespace GoodAdmin.Web.Core;

/// <summary>
/// 组织管理控制器
/// </summary>
[ApiDescriptionSettings("System", Tag = "组织管理")]
[Route("/system/org")]
[RoleDataScope]
public class OrgController:IDynamicApiController
{
    private readonly IExtraOrgService _extraOrgService;

    public OrgController(IExtraOrgService extraOrgService)
	{
        _extraOrgService = extraOrgService;
    }
    #region GET
    /// <summary>
    /// 分页查询
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpGet("page")]
    [DisplayName("分页查询")]
    public async Task<SqlSugarPagedList<SysOrg>> GetOrgPageList([FromQuery] OrgPageInput input)
    {
        return await _extraOrgService.GetOrgPageList(input);
    }
    #endregion

    #region POST
    /// <summary>
    /// 添加组织
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("add")]
    [DisplayName("添加组织")]
    public async Task AddOrg(OrgAddInput input)
    {
        await _extraOrgService.AddOrg(input);
    }

    /// <summary>
    /// 删除组织
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("delete")]
    [DisplayName("删除组织")]
    public async Task DeleteOrg(BaseIdInput input)
    {
        await _extraOrgService.DeleteOrg(input);
    }
    
    /// <summary>
    /// 更新组织
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("update")]
    [DisplayName("更新组织")]
    public async Task UpdateOrg(OrgUpdateInput input)
    {
        await _extraOrgService.UpdateOrg(input);
    }
    #endregion
}